<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:86:"/data/www/html/web2017/public_html/../application/index/view/usercenter/send_info.html";i:1493689316;}*/ ?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>发动态</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <!--<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">-->
    <link rel="stylesheet" href="__STATIC__/style/weui.min.css">
    <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/0.4.2/weui.min.css">
    <link rel="stylesheet" href="__STATIC__/style/cmgd.css">
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/js/layer/layer.js" ></script>
    <!--奥森图标-->
    <link rel="stylesheet" href="__STATIC__/style/FontAwesome_4.2.0/css/font-awesome.min.css">
    <style>
        .text{padding-left:9px; }
        .fa-list-ul{padding-right:8px;}
        .fa-meh-o{font-size:28px; padding-left: 2px;color:#999;}
        .fa-file-image-o{font-size:28px; padding-left: 2px; color:#999;}
        .weui_uploader_input_wrp,.weui_uploader_file{width:60px;height:60px;}
        .page.home .page__bd li { margin:0;padding-left: 5px;}
        a{color:#000;}
        .fa-angle-left{font-size:22px;}
    </style>
</head>
<body>

<div class="container" id="container">

    <!--顶部搜索-->
    <div class="page home js_show">


            <div class="page__bd" style="height: 100%;"  id="message">

                <div class="weui-flex">
                    <div>
                        <div class="placeholder">
                            <a href="<?php echo url('usercenter/dynamic'); ?>" >  <i class="fa fa-angle-left"></i></a>
                        </div>
                    </div>
                    <div class="weui-flex__item"><div class="placeholder" style="text-align: center;">发动态</div></div>
                    <div>
                        <div class="placeholder">
                            <a href="javascript:;" onclick="submit()">
                            <span style="font-size:14px;padding: 3px 5px; border:1px #ccc solid; border-radius: 5px;">发表</span></a>
                            </div>
                        </div>
                    </div>

                <div class="weui-cells weui-cells_form">
                    <div class="weui-cell">
                        <div class="weui-cell__bd">
                            <!--<textarea class="weui-textarea" name="content"  id="content" placeholder=" " rows="5">-->
                            <!--</textarea>-->
                            <span id="myform1"></span>
                            <div  id="myform" class="weui-textarea" contenteditable="true" style="height:100px; overflow: auto; float: left;">

                            </div>

                        </div>
                    </div>
                </div>

                <?php if($info['id'] != 0): ?>
                <div class="weui-panel weui-panel_access">
                    <div class="weui-panel__bd">
                        <a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
                            <div class="weui-media-box__hd">
                                <img class="weui-media-box__thumb" src="/uploads/face/<?php echo $info['head_img']; ?>" alt="">
                            </div>
                            <div class="weui-media-box__bd">
                                <h4 class="weui-media-box__title"><?php echo $info['nickname']; ?></h4>
                                <p class="weui-media-box__desc"><?php echo $info['content']; ?></p>
                            </div>
                        </a>
                    </div>
                </div>
                <?php endif; ?>







                <div id="emoji" class="emoji"  style="background:#fff; margin-top:10px;padding: 5px 0;display:none;">
                    <a href="javascript:;" onclick="addemoji(1)"> <span><img src="/static/emoji/img/1.gif"></span> </a>
                    <a href="javascript:;" onclick="addemoji(2)"><span><img src="/static/emoji/img/2.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(3)"><span><img src="/static/emoji/img/3.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(4)"><span><img src="/static/emoji/img/4.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(5)"><span><img src="/static/emoji/img/5.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(6)"><span><img src="/static/emoji/img/6.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(7)"><span><img src="/static/emoji/img/7.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(8)"><span><img src="/static/emoji/img/8.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(9)"><span><img src="/static/emoji/img/9.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(10)"><span><img src="/static/emoji/img/10.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(11)"><span><img src="/static/emoji/img/11.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(12)"><span><img src="/static/emoji/img/12.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(13)"><span><img src="/static/emoji/img/13.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(14)"><span><img src="/static/emoji/img/14.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(15)"><span><img src="/static/emoji/img/15.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(16)"><span><img src="/static/emoji/img/16.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(17)"><span><img src="/static/emoji/img/17.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(18)"><span><img src="/static/emoji/img/18.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(19)"><span><img src="/static/emoji/img/19.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(20)"><span><img src="/static/emoji/img/20.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(21)"><span><img src="/static/emoji/img/21.gif"></span></a>
                    <a href="javascript:;" onclick="addemoji(22)"><span><img src="/static/emoji/img/23.jpg"></span></a>
                </div>
                <?php if($info['img']==''): ?>
                <div class="weui_cells weui_cells_form" id="uploadimg" style="display:none;">
                    <div class="weui_cell">
                        <div class="weui_cell_bd weui_cell_primary">
                            <div class="weui_uploader">
                                <div class="weui_uploader_hd weui_cell">
                                    <div class="weui_cell_bd weui_cell_primary"></div>
                                    <div class="weui_cell_ft"><span id="imageCounter">0</span>/9</div>
                                </div>
                                <div class="weui_uploader_bd">
                                    <ul class="weui_uploader_files" id="files"></ul>
                                    <div class="weui_uploader_input_wrp" id="file_uploader">
                                        <input class="weui_uploader_input" type="file" id="file"
                                               name="file" accept="image/jpg,image/jpeg,image/png,image/gif">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>
                <p class="weui_cells_tips images_info"></p>

                <p class="weui_cells_tips "><i class="glyphicon glyphicon-map-marker"></i>
                    <span class="wx_cmgd_location"></span>
                    <input value='' type='hidden' name='address' id="address">
                </p>

                <div style="margin-top:10px;float:left;padding-left: 10px;" >
                    <a href="javascript:;" onclick="biaoqing()"> <i class="fa fa-meh-o" ></i> </a>
                    <input type="hidden" name="share_id" id="share_id" value="<?php echo $info['id']; ?>">
                    <p style="font-size: 12px;padding-left: 2px;">表情</p>
                </div>
                <?php if($info['img']==''): ?>
                <div style="margin-top:10px;float:left;padding-left: 10px;">
                    <a href="javascript:;" onclick="tupian()"> <i class="fa fa-file-image-o" ></i> </a>
                    <p style="font-size: 12px;padding-left: 2px;">图片</p>
                </div>
                <?php endif; ?>

                <div style="margin-top:10px;float:left;padding-left: 10px;">
                    <a href="javascript:;" onclick="at()"> <i class="fa fa-file-image-o" ></i> </a>
                    <p style="font-size: 12px;padding-left: 2px;">@</p>
                </div>




                <input type="hidden" name="imgs" id="imgs" value="">
                <input type="hidden" name="at_user_id" id="at_user_id" value="">
                <input type="hidden" name="at_people" id="at_people" value="">
                <!--<div class="weui-cells__title">上传封面</div>-->
                <!--<div class="weui-cells weui-cells_form" style="padding-top:6px;">-->
                    <!--<div class="weui-cell__bd">-->
                        <!--<div class="weui-uploader">-->
                            <!--<div class="weui-uploader__bd">-->
                                <!--<ul class="weui-uploader__files" id="uploaderFiles"></ul>-->
                                <!--<div class="weui-uploader__input-box">-->
                                    <!--<input id="uploaderInput" name="img" class="weui-uploader__input" type="file"  />-->
                                <!--</div>-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                <!--</div>-->
            </div>

        <div class="page__bd" style="height: 100%;" id="people">
            <div class="weui-panel">
                <div class="weui-panel__bd">
                    <div class="weui-media-box weui-media-box_small-appmsg">
                        <div class="weui-cells">
                            <?php if(is_array($myfocus) || $myfocus instanceof \think\Collection || $myfocus instanceof \think\Paginator): if( count($myfocus)==0 ) : echo "" ;else: foreach($myfocus as $key=>$myfocus): ?>
                                <a class="weui-cell weui-cell_access" href="javascript:;"  onclick="add_at(<?php echo $myfocus['fans_id']; ?>,'<?php echo $myfocus['nickname']; ?>')">
                                    <div class="weui-cell__hd">
                                        <img src="/uploads/face/<?php echo $myfocus['head_img']; ?>" alt="" style="width:30px;margin-right:10px;display:block">
                                    </div>
                                    <div class="weui-cell__bd weui-cell_primary">
                                        <p><?php echo $myfocus['nickname']; ?></p>
                                    </div>
                                </a>
                            <?php endforeach; endif; else: echo "" ;endif; ?>

                        </div>
                    </div>
                </div>
            </div>

        </div>


    </div>
</div>
</body>
<script type="text/javascript" src="/static/admin/webupload/webuploader.min.js"></script>
<script type="text/javascript">

    $('#people').hide();
    $(function() {

        $('#myform').focus(function () {
            $('#emoji').hide();
        });
    });



    function submit(){
       var text =  $("#myform").html();
       var share_id =  $("#share_id").val();
       var allimgs =   $('#imgs').val();
       var myform1 =   $('#at_user_id').val();

        if(text==''){
            layer.msg('请填写内容',{icon:5,time:1000,shade: 0.1,});
            return false;
        }
        $.post('<?php echo url("usercenter/send_info"); ?>',
                {content:text,share_id:share_id,imgs:allimgs,at_user_id:myform1},
                function(data){
                    if(data.code==1) {
                        layer.msg(text+data.msg,{icon:1,time:1000,shade: 0.1,});
                        location.href = '/index/usercenter/dynamic.html';
                        $("#myform").html('');
                        $('#emoji').hide();
                    }else{
                        layer.msg(data.msg,{icon:5,time:1000,shade: 0.1,});
                    }
                });
    }

    function biaoqing(){

        var status = $('#emoji').css('display');
        if(status=='none'){
            $('#emoji').css('display','block');
        }else{
            $('#emoji').css('display','none');
        }


    }


    function tupian(){

        var status1 = $('#uploadimg').css('display');
        if(status1=='none'){
            $('#emoji').css('display','none');
            $('#uploadimg').css('display','block');
        }else{
            $('#uploadimg').css('display','none');
        }
    }


    function addemoji(i){
       var htl = "<img src='/static/emoji/img/"+i+".gif'>";
        $("#myform").append(htl);
    }

    $(function() {
        var objUrl;
        var img_html;
        $("#file").change(function() {
            var count = $('#imageCounter').html();
            console.log(count);
            if(count>=9){
                layer.msg('最多上传9张图片',{icon:5,time:1500,shade: 0.1,});
                return false;
            }

            var files = $("#files");
            var filepath = $("input[name='file']").val();
            for(var i = 0; i < this.files.length; i++) {
                objUrl = getObjectURL(this.files[i]);

                var extStart = filepath.lastIndexOf(".");
                var ext = filepath.substring(extStart, filepath.length).toUpperCase();
                /*
                 作者：z@qq.com
                 时间：2016-12-10
                 描述：鉴定每个图片上传尾椎限制
                 * */
                if(ext != ".BMP" && ext != ".PNG" && ext != ".GIF" && ext != ".JPG" && ext != ".JPEG") {
                    $(".shade").fadeIn(500);
                    $(".text_span").text("图片限于bmp,png,gif,jpeg,jpg格式");
                    this.value = "";
                    $("#files").html("");
                    return false;
                } else {

                    var d = new Date();
                    var str = d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate();

                    var imgName =str+'\/'+(new Date()).valueOf() + ext;

                    upload(filepath,imgName,this.files[i]);

                    img_html = "<li class='weui_uploader_file' style='width:60px;height:60px;background-image: url(" + objUrl + ")'><button class='removeBtn' rel='"+ imgName +"' onclick='javascript:removeImg(this)'>X</button></li>";
//                    img_html += "  ";
                    files.append(img_html);

                  //  <input type = 'hidden' value='" + imgName+ "' name='imageName[]' >

                  var img1 =   $('#imgs').val();
                    img1 = img1+ imgName+','
                    $('#imgs').val(img1);
                }
            }

            var imageCounter = $(".removeBtn").size()?$(".removeBtn").size():0;
            $("#imageCounter").text(imageCounter);


            /*
             作者：z@qq.com
             时间：2016-12-10
             描述：鉴定每个图片大小总和
             * */
            var file_size = 0;
            var all_size = 0;
            for(j = 0; j < this.files.length; j++) {
                file_size = this.files[j].size;
                all_size = all_size + this.files[j].size;
                var size = all_size / 1024;
                if(size > 2000) {
                    $(".shade").fadeIn(2000);
                    $(".images_info").text(size+"上传的图片大小不能超过1M！");
                    this.value = "";
//                   $("#files").html("");
                    return false;
                }
            }

            return true;
        });
        /*
         作者：z@qq.com
         时间：2016-12-10
         描述：鉴定每个浏览器上传图片url 目前没有合并到Ie
         * */
        function getObjectURL(file) {
            var url = null;
            if(window.createObjectURL != undefined) { // basic
                url = window.createObjectURL(file);
            } else if(window.URL != undefined) { // mozilla(firefox)
                url = window.URL.createObjectURL(file);
            } else if(window.webkitURL != undefined) { // webkit or chrome
                url = window.webkitURL.createObjectURL(file);
            }
            return url;
        }


    });
    /*
     作者：z@qq.com
     时间：2016-12-10
     描述：上传图片附带删除 再次地方可以加上一个ajax进行提交到后台进行删除
     * */
    function removeImg(r){
//
        var imgName = $(r).attr("rel");
        remove(imgName);
//        console.log(imgName);
        $(r).parent().remove();
    }
    /*
     作者：z@qq.com
     时间：2016-12-10
     描述：上传图片附带放大查看处理
     * */
    function lookBigImg(b){
        $(".shadeImg").fadeIn(500);
        $(".showImg").attr("src",$(b).attr("src"))
    }
    /*
     作者：z@qq.com
     时间：2016-12-10
     描述：关闭弹出层
     * */
    function closeShade(){
        $(".shade").fadeOut(500);
    }
    /*
     作者：z@qq.com
     时间：2016-12-10
     描述：关闭弹出层
     * */
    function closeShadeImg(){
        $(".shadeImg").fadeOut(500);
    }


    function readFile(file){
//        var files = document.getElementById("files");

//        var file = this.files[0];


        if(!/image\/\w+/.test(file.type)){
            alert("文件必须为图片！");
            return false;
        }
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function(e){
            var u_r = this.result;
            return u_r;
//            files.innerHTML = '<img src="'+this.result+'" alt=""/>'
        }
    }

    function upload(imgPath,imgName,file){
        var formData = new FormData();
        var name = imgPath;
        formData.append("file",file);
        formData.append("imgpath",imgName);
        $.ajax({
            url : "<?php echo url('upload/upload'); ?>",
            type : 'POST',
            data : formData,
            processData : false,
            contentType : false,
            success : function(responseStr) {
                $(".images_info").text('');
                return responseStr;
            },
            fail:function(fail){
                $(".images_info").text(fail);
            }
        });
    }

    function remove(imgName){
        console.log(imgName);
        var formData = new FormData();
        formData.append("imgName",imgName);

        var img1 =   $('#imgs').val();
        var strs =imgName+',';

        img1 =img1.replace(strs, "")


        $('#imgs').val(img1);






//        $.ajax({
//            url : "/mobile/user/remove_img",
//            type : 'POST',
//            data : formData,
//            processData : false,
//            contentType : false,
//            success : function(responseStr) {
//                $(".images_info").text(responseStr);
//            }
//        });
    }



    function add_at(k,w){
        //console.log(k);
       var at_user_id = $('#at_user_id').val();
        $('#at_user_id').val(at_user_id+k+',');
        var mfm =  $('#myform1').html()
        mfm1 = '@'+w+'&nbsp;'+mfm;
        $('#message').show();
        $('#people').hide();
        $("#myform1").html(mfm1);
    }

    function at(){

        $('#message').hide();
        $('#people').show();

    }




</script>

</html>